function * foo(){
    console.log('start');
    try{
    const res=yield 'foo'
    console.log(res);
    }catch(e){
        console.log(e);
    }
}

const generator=foo()//得到生成器对象
const result=generator.next()//调用next方法才会开始执行 done属性{value:'foo',done:false}
console.log(result);// done属性{value:'foo',done:false} 执行到yield 'foo'

generator.next('bar')//这一步会yield 'bar' res=bar
generator.throw(new Error('Generator error'))


